<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>员工信息表</title>
<style>
*{ margin:0; padding:0;}
body{ font-size:14px; text-align:left;}
h3{ width:670px; height:30px; line-height:30px; text-align:center; margin:0 auto;}
td{ text-align:center; border:1px solid #799fc2;}
.bt{ background:#99cdff;}
form{ width:670px; height:auto; margin:0 auto;}
</style>

<?php
include 'connect.php';
$cid=$_GET['id'];


if ($_GET['action']=='edit'){
	move_uploaded_file($_FILES["file"]["tmp_name"], "images/" . $_FILES["file"]["name"]);
	$query = mysql_query("update tb_emp set e_name= '{$_POST['name']}',e_dept = '{$_POST['dept']}',date_of_birth= '{$_POST['birth']}',date_of_entry= '{$_POST['riqi']}',e_img='{$_FILES['file']['name']}' where e_id ='$cid'") or die( mysql_error());
	echo "<script type='text/javascript'>alert('修改成功');</script>";
}

$_query = mysql_query("select * from tb_emp where e_id = ".$_GET['id']);
$_rows = mysql_fetch_array($_query,MYSQL_ASSOC);

?>
</head>
<body>
   <h3>员工信息修改</h3>

  
	  <form id="form1" name="form1" method="post" action="?action=edit&id=<?php echo $_GET['id'];?>" style="padding:0 0 0 100px;" enctype="multipart/form-data">
      
          <table width="400" border="1" align="center">
          <tr>
              <td align="right">编号:</td>
              <td><?php echo $_rows['e_id'];?></td>
			 
            </tr>
             <tr>
              <td align="right">姓名:</td>
              <td><input name="name" type="text" value="<?php echo $_rows['e_name'];?>"/ ></td>
			 
            </tr>
              <tr>
              <td align="right">部门:</td>
              <td><input name="dept" type="text" value="<?php echo $_rows['e_dept'];?>"/ ></td>
			 
            </tr>
              <tr>
              <td align="right">头像:</td>
              <td><img src="images/<?php echo $_rows['e_img']; ?>"width=30px height=auto></td>
              
			 </tr>
             <tr>
               <td>选择头像</td>
             <td><input type="file" name="file" id="file"  value=""/> </td></tr>
          
                <tr>
              <td align="right">出生日期:</td>
              <td><input name="birth" type="text" value="<?php echo $_rows['date_of_birth'];?>"/ ></td>
			 
            </tr>
                <tr>
              <td align="right">入职日期:</td>
              <td><input name="riqi" type="text" value="<?php echo $_rows['date_of_entry'];?>"/ ></td>
			 
            </tr>
		
              <td colspan="2" align="center"><input type="submit" name="submit" value="修改" />  <a href="index.php">返回</a></td>
            </tr>
          </table>
          <p align="center">&nbsp;</p>
		
    </form>


</body>
</html>
